home *** CD-ROM | disk | FTP | other *** search
- #!xchat
- # @(#) dial.hayes V1.0 Thu Feb 13 14:24:49 1992 (Bob Denny)
- #
- # xchat script for dialing a vanilla Hayes modem
- #
- # Usage:
- # xchat dial.hayes telno
- #
- # where telno is the telephone number, subject to pause and wait
- # character modification.
- #
- # Uncomment the first two lines after "start:" to get debugging
- # in file "debug.log".
- #
- # Flush input, zero counter, set telephone number if supplied,
- # else fail if no telephone number given.
- #
- start:
- # dbgfile debug.log
- # dbgset 15
- zero
- flush
- ifnstr notelno 0
- telno 0
- goto initmodem
- #
- # Missing telephone number.
- #
- notelno:
- logerr No telephone number given
- failed
- #
- # Reset the modem to nonvolatile profile.
- # Allow 3 sec. for response, as some modems are slow to reset.
- #
- initmodem:
- count
- ifgtr cantinit 4
- send ATZ\r
- timeout initmodem 3000
- expect setupmodem OK
- expect ring RING\r
- #
- # No response from modem
- #
- cantinit:
- logerr Can't wake modem
- failed
- #
- # Send the stuff needed to initialize the modem to the modes
- # needed for the particular modem flavor. The string below
- # is provided as a vanilla example. Allow 2 sec. for the
- # modem to respond to this command.
- #
- setupmodem:
- ifnstr checkspeed 1
- sleep 1000
- send at
- sendstr 1 # take parameters from 2nd arg
- send \r
- timeout setupfail 2000
- expect setupfail ERROR
- expect checkspeed OK
- expect ring RING\r
- #
- # Modem barfed or died on setup command.
- #
- setupfail:
- logerr Error in modem setup string
- failed
- #
- # log the line speed to the modem
- #
- checkspeed:
- send ats20?\r
- expect s9600 007\r
- expect s19200 003\r
- expect s38400 002\r
- expect s76800 000\r
- expect ring RING\r
- timeout cspeedfail 2000
- #
- cspeedfail:
- logerr speed unkown or < 9600
- goto dialnumber
- #
- s9600:
- log port at 9600 bps
- goto dialnumber
- #
- s19200:
- log port at 19200 bps
- goto dialnumber
- #
- s38400:
- log port at 38400 bps
- goto dialnumber
- #
- s76800:
- log port at 76800 bps
- goto dialnumber
- #
- # Dial the supplied number. Handle the various errors that
- # can come back from the modem by logging the error.
- #
- dialnumber:
- zero
- retry:
- ifgtr busy 99 # retry this often before giving up on BUSY
- count
- timeout atd 3500
- expect ring RING\r
- #
- atd:
- send ATD
- dial
- send \r
- flush
- timeout timeout 90000
- expect connected CONNECT\s
- expect done CONNECT\r
- expect done CONNECT\n
- expect retry BUSY
- expect nocarrier NO CARRIER
- expect noanswer NO ANSWER
- expect nodialtone NO DIALTONE
- expect ring RING\r
- #
- # Success!
- #
- connected:
- timeout done 5000
- logstr CONNECT
- expect done \n
- #
- done:
- timeout ok 5000
- ifcarr ok
- nocd:
- logerr CONNECT but no carrier!?
- ok:
- success
- #
- # Handle modem dial failures
- #
- timeout:
- logerr Modem or carrier timeout.
- failed
- busy:
- logerr BUSY after 99 retries
- failed
- nocarrier:
- logerr NO CARRIER
- failed
- noanswer:
- logerr NO ANSWER
- failed
- nodialtone:
- logerr NO DIALTONE
- failed
- ring:
- logerr RING
- failed
- #
- # end
- #
-
-